Get the current memory address and the length¶
A.buffer_info() A.itemsize
Get the current memory address and the length in elements of the buffer used to hold an array’s contents and also find the size of the memory buffer in bytes.
from array import *
AI = array('i', [1, 3, 5, 7, 9])
print("Original array: " + str(AI))
# Original array: array('i', [1, 3, 5, 7, 9])
print("Current memory address and the length in "
"elements of the buffer: " + str(AI.buffer_info()))
# Current memory address and the length in
# elements of the buffer: (66925936, 5)
print("The size of the memory buffer in bytes: " +
str(array_num.buffer_info()[1] * AI.itemsize))
# The size of the memory buffer in bytes: 20
See also: https://www.w3resource.com/python-exercises/array/python-array-exercise-5.php